﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<!--中文书库详细页面-->
<%
    BIZ.BookOper bOper=new BIZ.BookOper();
    IList list = (IList)ViewData["bookinfo"];
    Hashtable tb = (Hashtable)list[0];
     %>
<div class="book_detail_box w_980">
	<!--top-->
	<div class="book_detail_ifno clearfix">
    	<!--left-->
    	<div class="book_detail_left">
        	<div class="book_detail_left_img"><img src="<%=BIZ.StringTool.changeImgUrl((tb["lb_cover"] == null ? "" : tb["lb_cover"].ToString())) %>" /></div>
            <div class="book_detail_left_btn">
            <% if(Session["user"]==null)
               {
                   Response.Write("<a  href=\"/Login/Login.html?f=" + Request.Url + "\"  title=\"加入收藏\" class=\"btn_fav\">加入收藏</a>");
                   if (int.Parse(tb["lb_ebook"].ToString()) != (int)DAL.Enums.bookebook.电子书)
                   {
                       if (int.Parse(tb["lb_state"].ToString()) == (int)DAL.Enums.bookState.下架)
                           Response.Write("<a href=\"#\" class=\"btn_xj\">已经下架</a>");
                       else if (int.Parse(tb["lb_inventory"].ToString()) <= 0)
                           Response.Write("<a href=\"#\" class=\"btn_nobook\">没有库存</a>");
                       else
                           Response.Write("<a href=\"/Login/Login.html?f=" + Request.Url + "\" class=\"btn_buy\">加入购物车</a>");
                   }
               }
               else
               {
                   Response.Write("<a href=\"javascript:void(0);\" onclick=\"Favorites(" + tb["lb_id"] + ")\"  title=\"加入收藏\" class=\"btn_fav\">加入收藏</a>");
                   if (int.Parse(tb["lb_ebook"].ToString()) != (int)DAL.Enums.bookebook.电子书)
                   {
                       if (int.Parse(tb["lb_state"].ToString()) == (int)DAL.Enums.bookState.下架)
                           Response.Write("<a href=\"#\" class=\"btn_xj\">已经下架</a>");
                       else if (int.Parse(tb["lb_inventory"].ToString()) <= 0)
                           Response.Write("<a href=\"#\" class=\"btn_nobook\">没有库存</a>");
                       else
                           Response.Write("<a href=\"#\" onclick=\"addLibrary(" + tb["lb_id"] + ",'" + tb["lb_bookName"] + "','" + tb["lb_translatedName"] + "'," + tb["lb_forAge"] + "," + tb["lb_price"] + "," + tb["lb_level"] + ",'" + tb["lb_cover"] + "')\" class=\"btn_buy\">加入购物车</a>");
                   }
               } %>
            	
            </div>
        </div>
    	<!--right-->
    	<div class="book_detail_right">
        	<h2><%=tb["lb_bookName"]%></h2>
            <%
                if (!string.IsNullOrEmpty(tb["lb_translatedName"].ToString()))
                    Response.Write("<p>译名：<strong>" + tb["lb_translatedName"] + "</strong></p>");
            %>
            <ul> 
            	<li><label>作  者：</label><span class="yellow_span"><%=tb["lb_author"]%></span>著</li>
            	<li><label>价格：</label><span class="price_span"><%=double.Parse(tb["lb_price"].ToString()).ToString("f2")%></span>元</li>
                <li><label>语种：</label><%=Enum.GetName(typeof(DAL.Enums.booklanguage), int.Parse(tb["lb_language"].ToString()))%></li>
                <li><label></label><%=Enum.GetName(typeof(DAL.Enums.bookebook), int.Parse(tb["lb_ebook"].ToString()))%></li>               
                <li><label>类型：</label><%=Enum.GetName(typeof(DAL.Enums.bookType),int.Parse(tb["lb_bookType"].ToString())) %></li>
                <li><label>级别：</label><%=Enum.GetName(typeof(DAL.Enums.boollevel),int.Parse(tb["lb_level"].ToString())) %> </li>
                <li><label>适读年龄：</label><span class="yellow_span"><%=Enum.GetName(typeof(DAL.Enums.bookforAge),int.Parse(tb["lb_forAge"].ToString())).ToString().Replace("_","") %></span></li>
                <li>
                <%
                    if (!string.IsNullOrEmpty(tb["lb_press"].ToString()))
                        Response.Write("<label>出版社：</label><b>" + tb["lb_press"] + "</b>");
                %>
                <label>出版时间：</label><b><%=DateTime.Parse(tb["lb_time"].ToString()).ToString("yyyy年MM月dd日") %></b></li>
                <li><label>页数</label>：<b><%=tb["lb_pageSize"] %></b>
                <%
                    if (!string.IsNullOrEmpty(tb["lb_kb"].ToString()))
                        Response.Write("<label>开本：</label><b>" + Enum.GetName(typeof(DAL.Enums.bookKb), int.Parse(tb["lb_kb"].ToString())).ToString().Replace("_", "") + "</b>");
                    if (!string.IsNullOrEmpty(tb["lb_paper"].ToString()))
                        Response.Write("<label>纸张：</label><b>" + tb["lb_paper"] + "</b>");
                    if (!string.IsNullOrEmpty(tb["lb_bz"].ToString()))
                        Response.Write("<label>包装：</label><b>" + tb["lb_bz"] + "</b></li>");
                %>           
                <li><label>其他：</label>
                <%
                    int u_vip_flag=0;
                    if(Session["user"]!=null)
                    {
                        DomainModel.UserInfo user =(DomainModel.UserInfo)Session["user"];
                        if (user.u_vip == (int)DAL.Enums.uservip.正式会员)
                        {
                            u_vip_flag = 1;
                        }
                    }
                    
                    if ((tb["lb_aboutEbook"] != null ? tb["lb_aboutEbook"].ToString().Trim() : "") != "")
                    {
                        if (u_vip_flag==1)
                            Response.Write("&nbsp;<a href='" + BIZ.StringTool.changeImgUrl(tb["lb_aboutEbook"].ToString()) + "'>电子书</a>&nbsp;");
                        else
                            Response.Write("&nbsp;电子书&nbsp;");
                    }

                    if ((tb["lb_aboutMp3"] != null ? tb["lb_aboutMp3"].ToString().Trim() : "") != "")
                    {
                        if (u_vip_flag == 1)
                            Response.Write("&nbsp;<a href='" + BIZ.StringTool.changeImgUrl(tb["lb_aboutMp3"].ToString()) + "'>音频</a>&nbsp;");
                        else
                            Response.Write("&nbsp;音频&nbsp;");
                    }
                    if ((tb["lb_aboutCd"] != null?tb["lb_aboutCd"].ToString().Trim():"")!="")
                        Response.Write("&nbsp;CD&nbsp;");
                %>
                
                </li>
            </ul>
        </div>
    </div>
    <!--book_txt-->
    <div class=" book_txt_box">
    	<h3>内容简介</h3>
        <div class="book_txt_box_main">
        	<%=tb["lb_bookContent"] %>
        </div>
    </div>
    <!--book_txt-->
    <div class=" book_txt_box">
    	<h3>图书预览</h3>
        <div class="book_txt_box_main">
        	<%=tb["lb_bookPreview"] %>
        </div>
    </div>
    <!--bottom_box-->
    
        <!--借过此书家长-->
            <%
            IList ul=bOper.getUserNameByBookId(int.Parse(tb["lb_id"].ToString()));
            IList appraisalList = bOper.getappraisal(int.Parse(tb["lb_id"].ToString()));
            if (ul.Count > 0 || appraisalList.Count > 0)
            {
                Response.Write("<div class=\"boook_detail_bottom_box\">");
                if (ul.Count > 0)
                {
                    Response.Write("<div class=\"book_box_01\">");
                    Response.Write("<h4>借过此书家长</h4>");
                    Response.Write("<ul class=\"clearfix\">");
                    foreach (Hashtable hs in ul)
                    {
                        Response.Write("<li>" + hs["uname"] + "</li>");
                    }
                    Response.Write("</ul>");
                    Response.Write("</div>");
                }
                //<!--家长评价-->       
                if (appraisalList.Count > 0)
                {
                    Response.Write("<div class=\"book_box_02\">");
                    Response.Write("<h4>家长评价</h4>");
                    Response.Write("<ul>");
                    foreach (Hashtable t in appraisalList)
                    {
                        Response.Write("<li><strong>" + t["uname"] + "：</strong>" + tb["lbi_appraisal"] + "</li>");
                    }
                    Response.Write("</ul>");
                    Response.Write(" </div>");
                }
                Response.Write("</div>");
            }
                 %>
</div>
<div id="dialog" title="图书收藏">
        目录:<select id="selDirectory" name="selDirectory">
        <option value="-1">请选择</option>
        <%
            if (Session["user"] != null)
            {
                DomainModel.UserInfo user = (DomainModel.UserInfo)Session["user"];
                BIZ.VipCenterOper v = new BIZ.VipCenterOper();
                IList l = v.getDirectoryList(user.u_id.ToString());
                foreach (Hashtable t in l)
                {
                    Response.Write("<option value=\"" + t["dl_id"] + "\">" + t["dl_name"] + "</option>");
                }
            }
             %>
        </select>
        <span id="msg" style="color:Red"></span>
        <input type="hidden" id="hid" name="hid" />
        </div>
<script type="text/javascript">
    function addLibrary(lb_id, lb_bookName, lb_translatedName, lb_forAge, lb_price, lb_level, lb_cover) {
        $.post("/search/addLibrary.html", { lb_id: lb_id, lb_bookName: lb_bookName, lb_translatedName: lb_translatedName, lb_forAge: lb_forAge, lb_price: lb_price, lb_level: lb_level, lb_cover: lb_cover }, function (dta) {
            if (dta == "have") {
                alert("该书已添加");
            }
            if (dta == "y") {
                alert("添加成功");
                window.location.reload();
            }
        });
    }
    //
    $(function () {
        // Dialog			
        $('#dialog').dialog({
            autoOpen: false,
            //modal: true,//如果要加遮罩层
            width: 350,
            buttons: {
                "确认": function () {
                    var id = $("#hid").val();
                    var dir = $("#selDirectory").val();
                    if (dir == "-1") {
                        $("#msg").text("请选择目录");
                        return false;
                    }
                    $.post("/search/saveUserSave.html?" + (new Date()).getTime(), { dlid: dir, lbid: id }, function (dta) {
                        if (dta == "have") {
                            $("#msg").text("该书已经收藏过，请不要重复收藏");
                        }
                        if (dta == "y") {
                            alert("收藏成功");
                            window.location.reload();
                        }
                    });
                }
            }
        });
    });
    // Dialog Link
    function Favorites(lbid) {
        $("#hid").val(lbid);
        $('#dialog').dialog('open');
        return false;
    }
</script>
</asp:Content>
